package com.ruoyi.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.order.domain.MesOrderPositionRecord;
import com.ruoyi.order.service.IMesOrderPositionRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓位占用记录Controller
 * 
 * @author guoxl
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/order/positionRecord")
public class MesOrderPositionRecordController extends BaseController
{
    @Autowired
    private IMesOrderPositionRecordService mesOrderPositionRecordService;

    /**
     * 查询仓位占用记录列表
     */
    @PreAuthorize("@ss.hasPermi('order:positionRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesOrderPositionRecord mesOrderPositionRecord)
    {
        startPage();
        List<MesOrderPositionRecord> list = mesOrderPositionRecordService.selectMesOrderPositionRecordList(mesOrderPositionRecord);
        return getDataTable(list);
    }

    /**
     * 导出仓位占用记录列表
     */
    @PreAuthorize("@ss.hasPermi('order:positionRecord:export')")
    @Log(title = "仓位占用记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesOrderPositionRecord mesOrderPositionRecord)
    {
        List<MesOrderPositionRecord> list = mesOrderPositionRecordService.selectMesOrderPositionRecordList(mesOrderPositionRecord);
        ExcelUtil<MesOrderPositionRecord> util = new ExcelUtil<MesOrderPositionRecord>(MesOrderPositionRecord.class);
        util.exportExcel(response, list, "仓位占用记录数据");
    }

    /**
     * 获取仓位占用记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:positionRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesOrderPositionRecordService.selectMesOrderPositionRecordById(id));
    }

    /**
     * 新增仓位占用记录
     */
    @PreAuthorize("@ss.hasPermi('order:positionRecord:add')")
    @Log(title = "仓位占用记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesOrderPositionRecord mesOrderPositionRecord)
    {
        return toAjax(mesOrderPositionRecordService.insertMesOrderPositionRecord(mesOrderPositionRecord));
    }

    /**
     * 修改仓位占用记录
     */
    @PreAuthorize("@ss.hasPermi('order:positionRecord:edit')")
    @Log(title = "仓位占用记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesOrderPositionRecord mesOrderPositionRecord)
    {
        return toAjax(mesOrderPositionRecordService.updateMesOrderPositionRecord(mesOrderPositionRecord));
    }

    /**
     * 删除仓位占用记录
     */
    @PreAuthorize("@ss.hasPermi('order:positionRecord:remove')")
    @Log(title = "仓位占用记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesOrderPositionRecordService.deleteMesOrderPositionRecordByIds(ids));
    }
}
